<template>
<div class="shop-wrap">
    <el-table :data="TableData.data" stripe style="width: 95%">
        <el-table-column prop="id" label="id" width="50"></el-table-column>
        <el-table-column prop="avatar" label="头像" width="91">
            <template slot-scope="scope">
                <el-avatar v-if="scope.row.avatar" :src="scope.row.avatar"></el-avatar>
                <el-avatar v-else>{{scope.row.title}}</el-avatar>
            </template>
        </el-table-column>
        <el-table-column prop="title" label="店铺名称" width="160"></el-table-column>
        <el-table-column prop="realname" label="联系人" width="160"></el-table-column>
        <el-table-column prop="mobile" label="联系电话" width="160"></el-table-column>
        <el-table-column prop="type" label="店铺类型" width="160">
            <template slot-scope="scope">
                <span v-if="scope.row.type == 1">VIP店铺</span>
                <span v-else>免费店铺</span>
            </template>
        </el-table-column>
        <el-table-column label="申请状态" width="180">
            <template slot-scope="scope">

                <el-link v-if="scope.row.pass_status === 'Apply'" type="success">申请中</el-link>
                <el-link v-if="scope.row.pass_status === 'Normal'" type="info">已通过</el-link>
                <el-link v-if="scope.row.pass_status === 'Fail'" type="danger">已驳回</el-link>

            </template>
        </el-table-column>
        <el-table-column fixed="right" label="操作" width="190">
            <template slot-scope="scope">
                <el-link type="primary" @click="floor(scope.row)" size="small">查看资料 </el-link>
                &nbsp;
                <el-link type="success" @click="passStatus(scope.row,'Normal')" size="small"> 通过审核</el-link>
                &nbsp;
                <el-link type="danger" @click="passStatus(scope.row,'Fail')" size="small"> 驳回</el-link>
            </template>
        </el-table-column>
       <div class="q-pagination" slot="append">
                    <el-pagination background layout="prev, pager, next" :total="TableData.total" @current-change="handlePageClick"></el-pagination>
                </div>
    </el-table>

    <el-dialog title="审核信息" :visible.sync="is_floor" width="50%" :before-close="handleClose">
        <el-card class="box-card">
            <div slot="header" class="clearfix">
                <span>营业执照</span>
                <el-button style="float: right; padding: 3px 0" type="text">操作按钮</el-button>
            </div>
            <div class="text item" v-if="information.certificate">
                <p>统一社会信用代码：{{information.certificate.social_credit_code}}</p>
                <p>名称：{{information.certificate.title}}</p>
                <p>类型：{{information.certificate.type}}</p>
                <p>经验场所：{{information.certificate.address}}</p>
                <p>法定代表人：{{information.certificate.legal_person}}</p>
                <p>注册资本：{{information.certificate.registered_capital}}</p>
                <p>成立日期：{{information.certificate.date_of_establishment}}</p>
                <p>营业期限：{{information.certificate.validity}}</p>
                <p>经验范围：{{information.certificate.remark}}</p>
            </div>
        </el-card>
        <span slot="footer" class="dialog-footer">
            <el-button @click="is_floor = false">取 消</el-button>
            <el-button type="success" @click="passStatus(information,'Normal')">通过审核</el-button>
            <el-button type="danger" @click="passStatus(information,'Fail')">驳回</el-button>
        </span>
    </el-dialog>

</div>
</template>

<script>
import {
    truncate
} from 'fs';
import axios from "axios";
export default {
    name: 'Shop',
    data() {
        return {
            is_floor: false,
            TableData: [],
            information: [],
            pageSize: 10
        }
    },
    mounted() {
        console.log('aaa');
        this.getStoreList();

    },
    methods: {
        async getStoreList(params = {}) {
            let _this = this;
            params.pageSize = this.pageSize
            axios.get("/api/store/admin/store/apply/", {
                    params
                })
                .then(result => {
                    _this.TableData = result.data.data;
                })
                .catch(_ => {
                    console.log(_);
                });
        },
        passStatus(row,status){
            console.log(row);
            let params = {}
            params.status = status
            axios.post("/api/store/admin/store/pass_status/"+row.id,params)
                .then(result => {
                    this.$message({
                    message: result.data.message,
                    type: 'success'
                    });
                    this.getStoreList();
                    if(this.is_floor == true){
                        this.is_floor = false
                    }
                })
                .catch(_ => {
                    console.log(_);
                });
        },
        floor(data) {
            this.is_floor = true
            this.information = data;
        },
        handlePageClick(e){
            this.getStoreList({
                page:e
            });
        }
    }
}
</script>

<style scoped></style>
